package org.lixf.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lixf.beans.Student;
import org.lixf.services.IStudentService;
import org.lixf.services.StudentServiceImpl;

public class RegisterServlet extends HttpServlet {

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String num = request.getParameter("num");
		String password = request.getParameter("password");
		String name = request.getParameter("name");
		String age = request.getParameter("age");
		String score = request.getParameter("score");
		
		Student student = new Student();
		student.setNum(num);
		student.setPassword(password);
		student.setName(name);
		student.setAge(Integer.parseInt(age));
		student.setScore(Double.parseDouble(score));
		
		IStudentService studentService = new StudentServiceImpl();
		studentService.register(student);
		
		response.sendRedirect(request.getContextPath() + "/login.jsp");
		
	}

}
